package flc.ast.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import com.blankj.utilcode.util.ToastUtils;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.databinding.ActivityForgetPwdBinding;
import flc.ast.utils.Content;
import stark.common.basic.utils.SPUtil;

public class ForgetPwdActivity extends BaseAc<ActivityForgetPwdBinding> {


    @Override
    protected int onCreate() {
        return R.layout.activity_forget_pwd;
    }

    @Override
    protected void initView() {
        mDataBinding.ivForgetPwdBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.ivCancel.setOnClickListener(v -> onBackPressed());
        mDataBinding.ivConfirm.setOnClickListener(this);

        String problem = SPUtil.getString(mContext, Content.myProblem, "");
        mDataBinding.tvQuestion.setText(problem);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.ivConfirm:
                String answer = SPUtil.getString(mContext, Content.myAnswer, "");
                String input = mDataBinding.etAnswer.getText().toString();
                if (TextUtils.isEmpty(input)) return;
                if (answer.equals(input)) {
                    startActivity(SetPwdActivity.class);
                } else {
                    ToastUtils.showShort(getString(R.string.answer_is_error));
                }
                break;
        }
    }

    @Override
    protected void initData() {

    }
}